# 执行前，统一的前置处理

# from util.connect_db import OperationMysql


# class GetData:
#
# 	def __init__(self,excel_sheel=None):
# 		if excel_sheel == None:
# 			self.opera_excel = OperationExcel()
# 		else:
# 			self.opera_excel = OperationExcel(excel_sheel)
# 		self.op_json = OperetionJson()
# 		self.path = FilePath()
# 		self.log = UserLog().get_log()
#
# 	def load_data(self):
# 		rows_count = self.get_case_lines()
# 		for i in range(1,rows_count):
# 			# 判断是否执行
# 			is_run = self.get_is_run(i)
# 			if is_run:
# 				data_list = self.get_line_data(i)
# 				yield data_list
#
# 	#去获取excel行数,就是我们的case个数
# 	def get_case_lines(self):
# 		return self.opera_excel.get_lines()
#
# 	# 通过row去获取该case的整行数据
# 	def get_line_data(self,row):
# 		rows_data = self.opera_excel.get_row_values(row)
# 		return rows_data
#
# 	# excel 生成器
# 	def get_data_generator(self,num=None):
# 		if num:
# 			rows_count = num
# 		else:
# 			rows_count = self.get_case_lines()
# 		# data_generator = []
# 		for i in range(1, rows_count):
# 			data_generator = self.get_line_data(i)
# 			yield data_generator
#
# 	#获取是否执行
# 	def get_is_run(self,row):
# 		flag = None
# 		col = int(col_num.get_run())
# 		run_model = self.opera_excel.get_cell_value(row,col)
# 		if run_model == 'yes':
# 			flag = True
# 		else:
# 			flag = False
# 		return flag
#
# 	#是否携带cookie
# 	def is_cookie(self,row):
# 		col = int(col_num.get_cookie())
# 		cookie = self.opera_excel.get_cell_value(row,col)
# 		if cookie != '':
# 			return cookie
# 		else:
# 			return None
#
# 	#获取请求方式
# 	def get_request_method(self,row):
# 		col = int(col_num.get_run_way())
# 		request_method = self.opera_excel.get_cell_value(row,col)
# 		return request_method
#
# 	def get_case_id(self,row):
# 		col = int(col_num.get_id())
# 		case_id = self.opera_excel.get_cell_value(row,col)
# 		return case_id
#
# 	def get_case_name(self,row):
# 		col = int(col_num.get_request_name())
# 		case_name = self.opera_excel.get_cell_value(row,col)
# 		return case_name
#
# 	#获取url
# 	def get_request_url(self,row):
# 		col = int(col_num.get_url())
# 		url = self.opera_excel.get_cell_value(row,col)
# 		return url
#
# 	# 返回host+url
# 	def get_request_url_host(self,row):
# 		col = int(col_num.get_id())
# 		case_id = self.opera_excel.get_cell_value(row,col)
# 		url = self.get_request_url(row)
# 		if 'tqyb'in case_id:
# 			host_url = url
# 		else:
# 			host = self.path.host(case_id)
# 			host_url = host+url
# 		return host_url
#
# 	# 获取excel的data关键字
# 	def get_request_data(self,row):
# 		col = int(col_num.get_data())
# 		data = self.opera_excel.get_cell_value(row,col)
# 		if data == '':
# 			return None
# 		return data
#
# 	# 通过data关键字,拿到data的json数据
# 	def get_data_for_dict(self,row):
# 		try:
# 			request_data = self.op_json.get_data(self.path.user(), self.get_request_data(row))
# 		except:
# 			request_data =None
# 		# if headers_type == 'json':
# 		# 	request_data = json.dumps(request_data)
# 		# 	self.log.debug('请求进行data格式处理，header_type为："%s"\n' % headers_type)
# 		return request_data
#
#
# 	# 获取excel的header关键字
# 	def get_header_data(self, row):
# 		col = int(col_num.get_header())
# 		header = self.opera_excel.get_cell_value(row, col)
# 		if header == '':
# 			return None
# 		return header
#
#
# 	# 通过header关键字拿到data的json数据
# 	def get_header_for_json(self,row):
# 		# header文件,path需要另外传参
# 		header_data = self.get_header_data(row)
# 		if header_data != None:
# 			request_header = self.op_json.get_data(self.path.header(),header_data)
# 			return request_header
# 		else:
# 			return None
#
# 	# 获取excel中的header_type
# 	def get_header_type(self,row):
# 		col = int(col_num.get_header_type())
# 		header_type = self.opera_excel.get_cell_value(row,col)
# 		if header_type == '':
# 			return None
# 		return header_type
#
#
#
# 	# 获取预期结果
# 	def get_expcet_data(self,row):
# 		col = int(col_num.get_expect())
# 		expect = self.opera_excel.get_cell_value(row,col)
# 		if expect == '':
# 			return ''
# 		return expect
#
# 	# #通过sql获取预期结果
# 	# def get_expcet_data_for_mysql(self,row):
# 	# 	op_mysql = OperationMysql()
# 	# 	sql = self.get_expcet_data(row)
# 	# 	res = op_mysql.search_one(sql)
# 	# 	return res.decode('unicode-escape')
#
# 	def write_result(self,row,value):
# 		col = int(col_num.get_result())
# 		self.opera_excel.write_value(row,col,value)
#
# 	# 获取依赖数据的key
# 	def get_depend_key(self,row):
# 		col = int(col_num.get_data_depend())
# 		depent_key = self.opera_excel.get_cell_value(row,col)
# 		if depent_key == "":
# 			return None
# 		else:
# 			return depent_key
#
# 	# 判断是否有case依赖
# 	def is_depend(self,row):
# 		col = int(col_num.get_case_depend_id())
# 		# 获取前置请求的case_id
# 		depend_case_id = self.opera_excel.get_cell_value(row,col)
# 		if depend_case_id == "":
# 			return None
# 		else:
# 			return depend_case_id
#
#
# 	def get_token(self,row):
# 		col = int(col_num.get_token())
# 		token = self.opera_excel.get_cell_value(row, col)
# 		if token != '':
# 			return token
# 		else:
# 			return None
#
# 	def get_result_key(self,row):
# 		col = int(col_num.get_result_key())
# 		result_key = self.opera_excel.get_cell_value(row,col)
# 		if result_key !='':
# 			return result_key
# 		else:
# 			return None


# if __name__ == '__main__':
# 	pass
# 	# a01 = GetData().get_request_url_host(6)
# 	# print(a01)
# 	a01 = GetData(2).get_data_generator()
# 	print(a01)

